package service.impl;

import dao.AccountDao;
import db.DBConnection;
import service.TransferService;

import java.sql.Connection;

public class TransferServiceImpl implements TransferService {
    private AccountDao accountDao = new AccountDao();
    @Override
    public boolean transfer(String from, String to, double money) throws Exception {
        Connection connection = DBConnection.getConnection();
        connection.setAutoCommit(false);
        if (accountDao.transfer(connection, from, to, money)) {
            connection.commit();
            return true;
        } else {
            connection.rollback();
            return false;
        }
    }
}
